{% extends 'layout.html' %}

{% block main %}
<link rel="stylesheet" href="/public/css/main.css">
<link rel="stylesheet" href="/public/css/bootstrap.min.css">
<div class="center">
    <div class="detail_main">
        <h2 class="detail_title">{{content.title}}</h2>
        <p class="detail_tag">日期：{{content.addTime | date('Y-m-d', -8*60)}} -阅读量：{{content.views}}</p>
        <input type="hidden" id="text-input" value="">
        <div class="detail_content" id="preview">{{content.content}}</div>
    </div>
</div>
<div class="detail_discuss">
    <div class="detail_main">
        <div class="discuss">
            <div class="user_tab">
                <span class="discuss_title">评论</span>
                <i></i>
            </div>
            <div class="discuss_main">
                <div class="discuss_content">
                    <ul class="discuss_list">

                    </ul>

                    <ul class="pager">
                        <li class="previous">
                            <a href="" >上一页</a>
                        </li>
                        <li></li>
                        <li class="next">
                            <a href="" >下一页</a>
                        </li>
                    </ul>

                    {% if userInfo.uid %}
                    <textarea class="discuss_input" name="" id="" cols="30" rows="10" placeholder="请在这写下评论～"></textarea>
                    <input class="discuss_id" type="hidden" value="{{content._id.toString()}}">
                    <p class="discuss_submit">提 交</p>
                    {% else %}
                    <p class="discuss_default">您还没有登录，请先登录～</p>
                    {% endif %}
                </div>
            </div>
        </div>
        <aside class="user_list">
            {% if userInfo.uid %}
            <div class="user_logined">
                {% if userInfo.isAdmin %}
                <p class="user_welcome">欢迎，<i>{{userInfo.username}}</i><a href="/admin">进入后台</a></p>
                {% else %}
                <p class="user_welcome">欢迎，<i>{{userInfo.username}}</i></p>
                {% endif %}
                <span id="loginOut" class="user_loginOut">退出</span>
            </div>
            {% else %}
            <div class="user_form">
                <div class="user_tab j_userTab">
                    <span class="user_cur">登录</span>
                    <span>注册</span>
                </div>
                <div id="login" class="user_login">
                    <div class="user_input">
                        <i class="iconfont">&#xe60d;</i>
                        <input type="text" placeholder="请输入用户名">
                    </div>
                    <div class="user_input margin_bottom0">
                        <i class="iconfont">&#xe6c6;</i>
                        <input type="password" placeholder="请输入密码">
                    </div>
                    <p class="user_err"><span>用户名不能为空</span></p>
                    <p class="user_login_btn">登 录</p>
                </div>
                <div id="register" class="user_register">
                    <div class="user_input">
                        <i class="iconfont">&#xe60d;</i>
                        <input type="text" placeholder="请输入用户名">
                    </div>
                    <div class="user_input">
                        <i class="iconfont">&#xe6c6;</i>
                        <input type="password" placeholder="请输入密码">
                    </div>
                    <div class="user_input margin_bottom0">
                        <i class="iconfont">&#xe6c6;</i>
                        <input type="password" placeholder="请再次输入密码">
                    </div>
                    <p class="user_err"><span>用户名不能为空</span></p>
                    <p class="user_register_btn">注 册</p>
                </div>
            </div>
            {% endif %}
            <div class="friendly_link">
                <div class="user_tab">
                    <span class="discuss_title">友情链接</span>
                </div>
                <div class="link_item">
                    <a href="http:www.zhihu.com">知乎</a>
                </div>
            </div>
            <p class="user_no">您是本网站的第<i>12</i>位访客祝您生活工作愉快</p>
            <p class="copy_right">京ICP备17059284号-1</p>
        </aside>
    </div>
</div>
<script src="/public/js/markdown.js"></script>
<script src="/public/js/main.js"></script>
<script>
    // 文章显示
    function Editor(input, preview) {
        this.update = function () {
            preview.innerHTML = markdown.toHTML(input.value);
        };
        input.editor = this;
        this.update();
    }
    var $$ = function (id) { return document.getElementById(id); };
    new Editor($$("text-input"), $$("preview"));
</script>
{% endblock %}